<template >
    <div class="login-container" style="background-image:url('/奶茶.jpg'); background-repeat: no-repeat; background-size: cover;" >
      <el-form :model="account" ref="loginForm" label-width="80px">
        <el-form-item label="用户名">
          <el-input v-model="account.loginname" placeholder="输入用户名"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="account.loginpwd" placeholder="输入密码" type="password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="dl">登录</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </template>

  <script>
  import { mapMutations } from 'vuex';

  export default {
    name: 'Login',
    data() {
      return {
        account: { loginname: 'admin', loginpwd: '123' },
      };
    },
    methods: {
      ...mapMutations(['SetLogin']),
      dl() {
        this.$axios({
          method: 'get',
          url: 'Sign',
          params: this.account,
        }).then((res) => {
          if (res.code === 1) {
            this.SetLogin(res.data);
            this.$message.success(res.msg);
            this.$router.push('/Index');
          } else {
            this.$message.error(res.msg);
          }
        });
      },
      resetForm() {
        this.$refs.loginForm.resetFields();
      },
    },
  };
  </script>

  <style scoped>
  .login-container {
    width: 600px; 
    min-height: 400px;
    margin: 10% auto;
    padding: 10px;
    border: 1px solid #e4e7ed;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    
  }
  
  </style>